package com.warmheart.builder.access;

import com.warmheart.core.co.base.BaseCoBuilder;
import com.warmheart.core.co.oper.Co;
import com.warmheart.core.cors.enums.DateFormatEnum;
import com.warmheart.entity.access.AccessPermission;

/**
 * 
 * @ClassName: AccessPermission
 * @Description: 权限实体CoBuilder类，对应表名称为tb_access_permission
 *               温馨提示：不要修改该实体CoBuilder类的任何字段
 * @author ZhangJianyang
 * @date 2025年06月16日 下午13:05:35
 *
 */
public class AccessPermissionCoBuilder extends BaseCoBuilder<AccessPermission, AccessPermissionCoBuilder> {

    private final AccessPermission t;

    @Override
    protected AccessPermissionCoBuilder self() {
        return this;
    }

    @Override
    public AccessPermission core() {
        return this.t;
    }

    public AccessPermissionCoBuilder(AccessPermission accessPermission) {
        t = accessPermission;
    }

    /**
     * 用户ID
     */
    private Co<AccessPermission, AccessPermissionCoBuilder> userId;

    /**
     * 资源类型
     */
    private Co<AccessPermission, AccessPermissionCoBuilder> resourceType;

    /**
     * 资源ID
     */
    private Co<AccessPermission, AccessPermissionCoBuilder> resourceId;

    /**
     * 访问类型
     */
    private Co<AccessPermission, AccessPermissionCoBuilder> accessType;

    /**
     * 是否临时权限
     */
    private Co<AccessPermission, AccessPermissionCoBuilder> state;

    /**
     * 来源申请ID
     */
    private Co<AccessPermission, AccessPermissionCoBuilder> sourceRequestId;

    /**
     * 过期时间
     */
    private Co<AccessPermission, AccessPermissionCoBuilder> expiresTime;

    public Co<AccessPermission, AccessPermissionCoBuilder> userId() {
        if (this.userId == null) {
            this.userId = new Co<AccessPermission, AccessPermissionCoBuilder>(self(), "user_id");
        }
        return this.userId;
    }

    public Co<AccessPermission, AccessPermissionCoBuilder> resourceType() {
        if (this.resourceType == null) {
            this.resourceType = new Co<AccessPermission, AccessPermissionCoBuilder>(self(), "resource_type");
        }
        return this.resourceType;
    }

    public Co<AccessPermission, AccessPermissionCoBuilder> resourceId() {
        if (this.resourceId == null) {
            this.resourceId = new Co<AccessPermission, AccessPermissionCoBuilder>(self(), "resource_id");
        }
        return this.resourceId;
    }

    public Co<AccessPermission, AccessPermissionCoBuilder> accessType() {
        if (this.accessType == null) {
            this.accessType = new Co<AccessPermission, AccessPermissionCoBuilder>(self(), "access_type");
        }
        return this.accessType;
    }

    public Co<AccessPermission, AccessPermissionCoBuilder> state() {
        if (this.state == null) {
            this.state = new Co<AccessPermission, AccessPermissionCoBuilder>(self(), "state");
        }
        return this.state;
    }

    public Co<AccessPermission, AccessPermissionCoBuilder> sourceRequestId() {
        if (this.sourceRequestId == null) {
            this.sourceRequestId = new Co<AccessPermission, AccessPermissionCoBuilder>(self(), "source_request_id");
        }
        return this.sourceRequestId;
    }

    public Co<AccessPermission, AccessPermissionCoBuilder> expiresTime(DateFormatEnum... dateFormatEnums) {
        if (this.expiresTime == null) {
            if (dateFormatEnums != null && dateFormatEnums.length > 0) {
                this.expiresTime = new Co<AccessPermission, AccessPermissionCoBuilder>(self(), "expires_time",
                        dateFormatEnums[0].getValue());
            } else {
                this.expiresTime = new Co<AccessPermission, AccessPermissionCoBuilder>(self(), "expires_time",
                        DateFormatEnum.yyyy_MM_dd.getValue());
            }
        }
        return this.expiresTime;
    }
}